SetCycleTime
设定 EtherCAT 周期时间。
语法
KsError SetCycleTime(
double Cycle
);
参数
Cycle:每秒插补周期时间。
回传值
如果此函式执行成功,会回传 errNoError,否则会传回错误码。如需更多有关错误码的资讯,请参阅 KsError 清单。
备注
- 此函式必须在 Create 后及 Start 前呼叫。
- 最低周期时间为 100 微秒,最高则为 2 毫秒。
- 欲使用低于 1 毫秒的周期时间,须备有高速计时器套件。
- 周期时间必须为 RTX64 HAL 周期的倍数。
- 若一从站无法跟上速度,各自从站的周期时间将自动增加。
- 建议的周期时间为 100 微秒、125 微秒、250 微秒、500 微秒、1 毫秒及 2 毫秒。
可用的 EtherCAT 状态
ecatOffline
范例
复制
//////////////////////////////////////////////////////////////////
//
// This code snippet demonstrates how to use subsystem configuration
// and axis variable APIs to configure the setting before starting
// KINGSTAR subsystem.
//
//////////////////////////////////////////////////////////////////
// Variable declaration
KsError nRet = errNoError;
KsCommandStatus Command = { 0 };
SubsystemStatus Subsystem = { ecatOffline, ecatOffline, 0, 0, 0, {ecatOffline}, {ecatOffline}, {axisOffline} };
double featStatus = -1.0;
// Link to the KINGSTAR subsystem
nRet = Create(0, 0);
// Configure the subsystem settings
// Before enable the features, please check if the corresponding licenses are all enabled
// in the runtime environment.
nRet = ConfigureDc(TRUE, TRUE, TRUE, 0);
nRet = EnableAutoConfig(TRUE);
nRet = EnableAutoRepair(TRUE);
nRet = EnableAutoRestart(TRUE);
nRet = EnableHotConnect(FALSE);
nRet = EnableRedundancy(FALSE);
nRet = EnableServerLog(FALSE);
nRet = SetCycleTime(cycle500);
// Configure the axis variables
// Before enabling variables in the program, you should:
// 1. Read the user manual to check if the variables are available in the device.
// 2. Check if the corresponding variables are put in the PDO list in ESI import tool.
// For further details, see Help System >> KINGSTAR ESI Import Tool >> Tabs >> PDO.
nRet = EnableActualCurrent(TRUE);
nRet = EnableActualTorque(TRUE);
nRet = EnableActualVelocity(TRUE);
nRet = EnableAxisInput(TRUE);
nRet = EnableAxisOutput(FALSE);
nRet = EnableFollowingError(TRUE);
nRet = EnableMaxCurrent(TRUE);
nRet = EnableMaxTorque(TRUE);
nRet = EnableProfilePosition(FALSE);
nRet = EnableSecondEncoder(FALSE);
nRet = EnableSynchronizedControlMode(TRUE);
nRet = EnableTorqueOffset(FALSE);
nRet = EnableTouchProbe(FALSE);
nRet = SetAxisAccessMode(accessPos); // Refer to KsAccessMode page for detailed introduction
// Subsystem setting can be checked anytime after successfully calling Create().
// It is useful to check the feature status when you save the settings in a .kst file
// and start the subsystem via StartFromConfiguration().
nRet = GetFeatureStatus(KsFeature::featureCycleTime, &featStatus);
// Start the EtherCAT network
// You can only configure the setting before starting the subsystem
// If you need to modify the setting, call Stop() first.
Command = WaitForCommand(30, TRUE, Start());
使用需求
| RT | Win32 | |
|---|---|---|
| 最低支援版本 | 4.0 | 4.0 |
| 标头档 | ksapi.h | ksapi.h |
| 程式库 | KsApi_Rtss.lib | KsApi.lib |
参见